package com.jonesun.test.javafx;


import com.jonesun.test.javafx.model.FormsFxModel;
import com.jonesun.test.javafx.view.FormsFxPane;
import javafx.application.HostServices;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import org.springframework.stereotype.Component;

@Component
public class SimpleUiController {
	private final HostServices hostServices;
	public VBox rootPane;

	SimpleUiController(HostServices aHostservices) {
		this.hostServices=aHostservices;
	}
	@FXML
	public Label label;
	@FXML
	public Button button;

	@FXML
	public void initialize() {
		String javaVersion = System.getProperty("java.version");
		String javafxVersion = System.getProperty("javafx.version");

		label.setText("Hello, This is JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
		this.button.setOnAction(actionEvent -> this.label.setText(this.hostServices.getDocumentBase()));

		FormsFxModel model = new FormsFxModel();
		FormsFxPane formsFxPanel = new FormsFxPane(model);

		rootPane.getChildren().add(formsFxPanel);

		label.textProperty().bind(model.getFormInstance().titleProperty());

	}
}
